Skip to content

Check bounding boxes and trees before starting neuron segmentation #8678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

knollengewaechs
Copy link
Contributor

@knollengewaechs knollengewaechs commented Jun 6, 2025

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • enable long-running jobs

  • create an annotation and open the AI jobs modal. select neuron segmentation. enable Evaluation settings. Either of the following conditions should yield a corresponding error toasts and prevent you from starting the job:

    • having no skeleton trees
    • having an empty skeleton (any trees without nodes)
    • having no user bounding boxes
    • having multiple user bounding boxes
    • having exactly one user bounding box and a task bounding box.
  • all this should be independent of the selected bounding box.

  • open the annotation of a finished task. if a bounding box appears in the bounding box tab, this bounding box should be selectable in the bounding box dropdown of the modal. after selecting it (given that there are skeletons with nodes), you should be able to start the job.

  • the scene controller was adjusted in the place where the task bounding boxes are updated. thus you should create some tasks with different bounding boxes and check after clicking Finish and get next task the lime green task bounding box is updated within the view port.

context

questions/feedback: https://scm.slack.com/archives/C5AKLAV0B/p1749201952606739

TODOs:

  • maybe incorporate feedback from slack

Issues:


(Please delete unneeded items, merge only when none are left open)

@knollengewaechs knollengewaechs self-assigned this Jun 6, 2025
Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

📝 Walkthrough

Walkthrough

The changes introduce validation logic to prevent starting split/merger evaluation jobs when the ground truth is unusable, such as missing or multiple bounding boxes, missing skeleton annotations, or empty skeleton trees. Explanatory UI text and localized error messages are added. Supporting utility functions and selector updates are also included.

Changes

Files/Paths Change Summary
frontend/javascripts/viewer/model/accessors/skeletontracing_accessor.ts Added hasEmptyTrees function to check for empty trees in a TreeMap.
frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx Added validation for bounding box and skeleton annotation presence, error handling, and UI explanatory text.
frontend/javascripts/messages.tsx Added a new localized error message for incorrect bounding box selection.
frontend/javascripts/viewer/controller/scene_controller.ts Refactored task bounding box update logic and adjusted selector for bounding boxes.
frontend/javascripts/viewer/model/accessors/tracing_accessor.ts Updated _getTaskBoundingBoxes to accept full state and adjusted its logic.
unreleased_changes/8678.md Added documentation about the new validation step before segmentation job initiation.

Assessment against linked issues

Objective Addressed Explanation
Recognize unusable ground truth (no bounding box, no tree, empty tree) before starting inference (evaluation) (#8537)
Prevent job start and show error message if ground truth is unusable (#8537)
Explain evaluation feature and ground truth requirements in the UI (#8537)

Suggested labels

frontend, bug

Suggested reviewers

  • knollengewaechs

Poem

A bounding box must stand alone,
With skeletons that clearly have grown.
No empty trees, no missing ground,
Or error toasts will soon resound!
Rabbits check before you start—
For flawless jobs, that's the art! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4a272 and 5c15084.

📒 Files selected for processing (1)
  • unreleased_changes/8678.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • unreleased_changes/8678.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests
  • GitHub Check: frontend-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@knollengewaechs knollengewaechs marked this pull request as ready for review June 11, 2025 12:53
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
frontend/javascripts/viewer/model/accessors/skeletontracing_accessor.ts (1)

120-122: Check NodeMap API & consider clearer naming

  1. tree.nodes.size() assumes NodeMap exposes a size() method. In several places of the code base I have seen size used as a property. Please double-check the actual API – a silent undefined is not a function at runtime would abort every job submission.
  2. The helper returns true when at least one tree is empty. Naming it hasEmptyTrees is therefore slightly ambiguous – something like containsEmptyTree/anyTreeEmpty communicates intent more clearly.

No blocker, but please verify (1) and, if you agree, adjust the name or add a short JSDoc.

frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx (1)

640-652: Small wording / accessibility nit

Inside the explanatory <div> the bullet list is wrapped in another <div> without a semantic heading; consider replacing the outer <div> by a <p> or <Fragment> and adding a <strong> heading so screen readers don’t flatten text & list into one blob.

Pure polish – feel free to ignore if UI copy is still in flux.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c240321 and e9177ac.

📒 Files selected for processing (2)
  • frontend/javascripts/viewer/model/accessors/skeletontracing_accessor.ts (1 hunks)
  • frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
frontend/javascripts/viewer/model/accessors/skeletontracing_accessor.ts (1)
frontend/javascripts/viewer/model/types/tree_types.ts (2)
  • TreeMap (94-94)
  • Tree (61-75)
frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx (3)
frontend/javascripts/libs/react_hooks.ts (1)
  • useWkSelector (292-294)
frontend/javascripts/viewer/model/accessors/tracing_accessor.ts (1)
  • getUserBoundingBoxesFromState (102-105)
frontend/javascripts/viewer/model/accessors/skeletontracing_accessor.ts (1)
  • hasEmptyTrees (120-122)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests
  • GitHub Check: frontend-tests
🔇 Additional comments (1)
frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx (1)

1122-1131: Guard clauses look good, just ensure consistent size() usage

This block now relies on trees.size() and on hasEmptyTrees (which internally calls size() as well). If NodeMap ever switches back to a size property, both checks would fail the same way. Once you have verified the API in the accessor file, no further action is required here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
frontend/javascripts/viewer/controller/scene_controller.ts (2)

338-345: Remove unused loop variable & consider deleting obsolete map entries

for (const [tracingId, _boundingBox] of Object.entries(this.taskCubeByTracingId)) { ... }
The second tuple element (_boundingBox) is never used – it can be omitted to avoid the ESLint no-unused-vars warning.

Additionally, instead of setting this.taskCubeByTracingId[tracingId] = null;, you could delete the key altogether to keep the map clean and avoid accumulating stale keys over time:

-for (const tracingId of Object.keys(this.taskCubeByTracingId)) {
-  const taskCube = this.taskCubeByTracingId[tracingId];
-  ...
-  this.taskCubeByTracingId[tracingId] = null;
-}
+for (const tracingId of Object.keys(this.taskCubeByTracingId)) {
+  const taskCube = this.taskCubeByTracingId[tracingId];
+  ...
+  delete this.taskCubeByTracingId[tracingId];
+}

This keeps memory usage deterministic and makes subsequent Object.entries iterations cheaper.


347-367: Minor cleanup: avoid redundant state look-ups and unused variable

Within the “add new entries” loop:

  • Store.getState() is called for every iteration only to test task == null. Capture the result once before the loop for efficiency (even if it’s run rarely).
  • let taskCube = this.taskCubeByTracingId[tracingId]; is assigned but never read before being overwritten. Remove the line to reduce noise.
-const { viewMode } = Store.getState().temporaryConfiguration;
+const { viewMode } = state.temporaryConfiguration;
 ...
-let taskCube = this.taskCubeByTracingId[tracingId];

These micro-cleanups improve readability without altering behaviour.

frontend/javascripts/viewer/model/accessors/tracing_accessor.ts (1)

94-99: Guard against undefined boundingBox values

Object.fromEntries(layers.map((l) => [l.tracingId, l.boundingBox])) will include entries whose boundingBox might be undefined.
Down-stream code partly copes with null, but undefined slips through the boundingBox == null check (undefined == nulltrue) and causes an unnecessary key that is immediately discarded in updateTaskBoundingBoxes.

Filter here to return only layers with a concrete bounding box:

-return Object.fromEntries(layers.map((l) => [l.tracingId, l.boundingBox]));
+return Object.fromEntries(
+  layers
+    .filter((l) => l.boundingBox != null)
+    .map((l) => [l.tracingId, l.boundingBox]),
+);

This keeps the selector purer and reduces needless churn in the scene controller.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c458eb6 and d73119d.

📒 Files selected for processing (4)
  • frontend/javascripts/messages.tsx (1 hunks)
  • frontend/javascripts/viewer/controller/scene_controller.ts (2 hunks)
  • frontend/javascripts/viewer/model/accessors/tracing_accessor.ts (1 hunks)
  • frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx (6 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/javascripts/messages.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx
🧰 Additional context used
🧬 Code Graph Analysis (2)
frontend/javascripts/viewer/controller/scene_controller.ts (1)
frontend/javascripts/viewer/model/accessors/tracing_accessor.ts (1)
  • getTaskBoundingBoxes (101-101)
frontend/javascripts/viewer/model/accessors/tracing_accessor.ts (2)
frontend/javascripts/viewer/store.ts (1)
  • WebknossosState (559-579)
frontend/javascripts/test/fixtures/skeletontracing_server_objects.ts (1)
  • annotation (167-219)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests

@knollengewaechs
Copy link
Contributor Author

@philippotto I read the slack conversation again and understood that the checks I should be doing are independant of the selcted bounding box. Thus I applied this, in addition to the things we discussed this morning.

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, lgtm 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent starting inference with evaluation when ground truth is unusable
3 participants